package fr.ants.view.renderer.pixel;

import java.awt.Graphics2D;

import fr.ants.model.Nest;
import fr.ants.view.panel.Canvas;
import fr.ants.view.renderer.NestRenderer;

/**
 * <p>Renders a nest with pixels.</p> 
 *
 * @author Vianney DUPOY DE GUITARD
 */
public class NestPixelRenderer implements NestRenderer {

	/** Color mapper. */
	private ColorMap colorMap;

	/**
	 * Creates a new renderer.
	 * @param pColorMap : the color mapping used.
	 */
	public NestPixelRenderer(ColorMap pColorMap) {
		colorMap = pColorMap;
	}

	/** {@inheritDoc} */
	public void draw(int x, int y, Graphics2D g, Nest nest) {
		if (nest.getAnts().size() > 0) {
			g.setColor(colorMap.getColor(nest));
			g.fillOval(x * Canvas.NODE_SIZE, y * Canvas.NODE_SIZE, Canvas.NODE_SIZE, Canvas.NODE_SIZE);
		}
	}
}